/****************************************************
    文件：Player.cs
	作者：Jack
    日期：#CreateTime#
	功能：Nothing
*****************************************************/

using UnityEngine;

public class Player : MonoBehaviour 
{
    private Rigidbody2D rb;
    public float speed;
    private float inputX, inputY;
    private Vector2 movementInput;

    private void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    private void Update()
    {
        PlayerInput();
    }
    private void FixedUpdate()
    {
        MoveMent();
    }
    private void PlayerInput()
    {
        inputX = Input.GetAxisRaw("Horizontal");
        inputY= Input.GetAxisRaw("Vertical");
        if(inputX!=0&&inputY!=0)
        {
            inputX = inputX * 0.6f;
            inputY = inputY * 0.6f;
        }
        movementInput=new Vector2 (inputX, inputY);
    }

    private void MoveMent()
    {
        rb.MovePosition(rb.position+movementInput*speed*Time.deltaTime);
    }
}